import axios from "./axios-config";

// 请求模型初始化训练
export function trainModelService() {
  const res = axios.post("/model/trainModel");
  return new Promise((resolve, reject) => {
    res
      .then((result) => {
        console.log("result", result);
        if (result.status === 200) {
          return result.data;
        } else {
          reject(result.status);
        }
      })
      .then((json) => {
        resolve(json);
      })
      .catch((e) => {
        reject(e.toString());
      });
  });
}

// 请求模型预测
export function predictModelService() {
    const res = axios.post("/model/predictModel");
    return new Promise((resolve, reject) => {
      res
        .then((result) => {
          console.log("result", result);
          if (result.status === 200) {
            return result.data;
          } else {
            reject(result.status);
          }
        })
        .then((json) => {
          resolve(json);
        })
        .catch((e) => {
          reject(e.toString());
        });
    });
  }
